package holdem.Rulegui;

import java.io.Serializable;

import holdem.ListInt;




public class ActionExpresion implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8209714766640318034L;
	
	public Code Lvalue;
	public Expression Rvalue;
	
	
	public ActionExpresion(){}
	public ActionExpresion(Code code, Expression ex){
		Lvalue = code;
		Rvalue = ex;

	}
	
	public void Action(GeneticCode code, ListInt WM , ListInt modifyRelm){
		int value = Rvalue.EvalExp(code, WM,code);
		Lvalue.parse(code, modifyRelm).set(value);
	}
	public static ActionExpresion Load(String s){
		ActionExpresion Rval = new ActionExpresion();
		int i;
		for( i = 0; i < s.length(); i++){
			if(s.charAt(i) == '='){
				break;
			}
		}
		Rval.Lvalue = Code.load(s.substring(0, i));
		Rval.Rvalue = Expression.load(s.substring(i+1));
		return Rval;
	}
	public String saveString(){
	
		return Lvalue.saveString() + "=" + Rvalue.saveString();
	}
	
}
